package com.app.studyroom;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class FaceRecognitionActivity extends BaseActivity {

    private String identity; // user 或 admin 身份标识

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_face_recognition);

        identity = getIntent().getStringExtra("identity");

        TextView textView = findViewById(R.id.face_recognition_info);
        textView.setText("身份：" + identity + "，请开始人脸识别登录。");

        // TODO: 这里应替换为真实的人脸识别成功回调
        simulateFaceLogin();
    }

    // 模拟识别成功后跳转
    private void simulateFaceLogin() {
        textViewDelayed("人脸识别成功，正在跳转...", 1500);
        loginSuccess();
    }

    private void loginSuccess() {
        Intent intent;
        if ("user".equals(identity)) {
            intent = new Intent(this, PersonalCenterActivity.class);
        } else {
            intent = new Intent(this, AdminDashboardActivity.class);
        }
        startActivity(intent);
        finish();
    }

    // 可选：延迟显示文字，模拟识别过程
    private void textViewDelayed(String msg, int delayMillis) {
        TextView textView = findViewById(R.id.face_recognition_info);
        textView.postDelayed(() -> textView.setText(msg), delayMillis);
    }
}
